From b4abdb00ef83aa824e8a05d5b75df48adb7b9629 Mon Sep 17 00:00:00 2001
From: Rafi Zadanly <zadanlyr@gmail.com>
Date: Wed, 3 May 2023 10:38:52 +0700
Subject: semi dynamic page

---
 src/pages/shop/product/[slug].jsx | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

(limited to 'src/pages/shop/product/[slug].jsx')

diff --git a/src/pages/shop/product/[slug].jsx b/src/pages/shop/product/[slug].jsx
index 7ab0ef76..ed6c27d5 100644
--- a/src/pages/shop/product/[slug].jsx
+++ b/src/pages/shop/product/[slug].jsx
@@ -4,24 +4,22 @@ import { getIdFromSlug } from '@/core/utils/slug'
 import productApi from '@/lib/product/api/productApi'
 import dynamic from 'next/dynamic'
 import { useRouter } from 'next/router'
-import { useEffect, useState } from 'react'
 
 const BasicLayout = dynamic(() => import('@/core/components/layouts/BasicLayout'))
 const Product = dynamic(() => import('@/lib/product/components/Product/Product'))
 
 export async function getServerSideProps(context) {
   const { slug } = context.query
-  
+
   let product = await productApi({ id: getIdFromSlug(slug) })
   if (product?.length == 1) {
     product = product[0]
     const regexHtmlTags = /(<([^>]+)>)/gi
     const regexHtmlTagsExceptP = /<\/?(?!p\b)[^>]*>/g
-    if (product.description.replace(regexHtmlTags, ' ').trim() == '') {
-      product.description = ''
-    }
-    product.description = product.description.replace(regexHtmlTagsExceptP, ' ')
-    product.description = product.description.trim()
+    product.description = product.description
+      .replace(regexHtmlTagsExceptP, ' ')
+      .replace(regexHtmlTags, ' ')
+      .trim()
   } else {
     product = null
   }
-- 
cgit v1.2.3

